9405. Professor and balloons
For the holiday, the Professor bought blue,
red, and yellow balloons. In total he bought n balloons. There are a
yellow and blue balloons together. There are b red and blue balloons
together.
How many blue, red and yellow balloons did
the Professor buy?
Input. Three positive integers n, a, b.
Output. Print in one line the number of blue, red and yellow balloons that the Professor bought.
Sample
input |
Sample
output |
10 6 8 |
4 4 2 |
mathematics
Let the number of blue, red and yellow
balls be respectively blue, red and yellow. According to
the condition of the problem, it is known that:
·
yellow + blue = a
(yellow and blue balloons);
·
red + blue = b
(red and blue balloons);
·
blue + red + yellow = n (there are n balloons in total)
· red = n – a;
· yellow = n – b;
· blue = a + b – n;
Read the input data.
scanf("%d %d %d", &n, &a, &b);
Compute and print the answer.
blue = a + b - n;
red = n - a;
yellow = n - b;
printf("%d %d %d\n", blue, red, yellow);
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
int n = con.nextInt();
int a = con.nextInt();
int b = con.nextInt();
int blue = a + b - n;
int red = n - a;
int yellow = n - b;
System.out.println(blue + " " + red + "
" + yellow);
con.close();
}
}
Read the input data.
n, a, b = map(int,input().split())
Compute and print the answer.
blue = a + b - n;
red = n - a;
yellow = n - b;
print(blue, red, yellow);